//
// Created by 张兮兮 on 2025/3/12.
//

#ifndef SOCKETPRO_SERVER_H
#define SOCKETPRO_SERVER_H
#include "Python.h"
#include <QObject>
#include <QLocalServer>
#include <QLocalSocket>

#include <chrono>

class Server : public QObject
{
Q_OBJECT

public:
    explicit Server(QObject *parent = nullptr);
    ~Server();

    void startServer(const QString &processId);
    void initializePython(const std::string &pythonPath);

private:
    QLocalServer *server;
    QLocalSocket *currentSocket;
    PyObject *pFunc;
    pid_t pidA;

    uint64_t getCurrentMillis();
    void handlePythonResult(PyObject *pResult);
    void checkProcessA();
    void processImageData(const QByteArray &imageData,bool isTest);

private slots:
    void handleNewConnection();
};

#endif //SOCKETPRO_SERVER_H
